package com.zj.joke.adapter;

import com.zj.joke.R;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class GuideAdapter extends PagerAdapter {
	private Context mCtx;
	private int[] resIds = { R.drawable.img_guide_1, R.drawable.img_guide_2,
			R.drawable.img_guide_3, R.drawable.img_guide_4 };

	public GuideAdapter(Context ctx) {
		this.mCtx = ctx;
	}

	@Override
	public Object instantiateItem(ViewGroup collection, int position) {
		LayoutInflater inflater = LayoutInflater.from(mCtx);
		View view = inflater.inflate(R.layout.guide_item, null);
		ImageView image = (ImageView) view.findViewById(R.id.guideImgBack);
		image.setImageResource(resIds[position]);
		collection.addView(view, 0);
		return view;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView((View) object);
	}

	@Override
	public int getCount() {
		return resIds == null ? 0 : resIds.length;
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view == object;
	}

}
